import Vue from 'vue'
import { login, logout, phoneLogin } from "@/api/login"
import { ACCESS_TOKEN, USER_NAME,USER_INFO,USER_AUTH,SYS_BUTTON_AUTH } from "@/store/mutation-types"
import { welcome } from "@/utils/util"
import { queryPermissionsByUser } from '@/api/api'
import { getAction } from '@/api/manage'

const user = {
  state: {
    token: '',
    username: '',
    realname: '',
    welcome: '',
    avatar: '',
    permissionList: [],
    info: {}
  },

  mutations: {
    SET_TOKEN: (state, token) => {
      state.token = token
    },
    SET_NAME: (state, { username, realname, welcome }) => {
      state.username = username
      state.realname = realname
      state.welcome = welcome
    },
    SET_AVATAR: (state, avatar) => {
      state.avatar = avatar
    },
    SET_PERMISSIONLIST: (state, permissionList) => {
      state.permissionList = permissionList
    },
    SET_INFO: (state, info) => {
      state.info = info
    },
  },

  actions: {
    // CAS验证登录
    ValidateLogin({ commit }, userInfo) {
      return new Promise((resolve, reject) => {
        getAction("/cas/client/validateLogin",userInfo).then(response => {
          console.log("----cas 登录--------",response);
          if(response.success){
            const result = response.result
            const userInfo = result.userInfo
            Vue.ls.set(ACCESS_TOKEN, result.token, 7 * 24 * 60 * 60 * 1000)
            Vue.ls.set(USER_NAME, userInfo.username, 7 * 24 * 60 * 60 * 1000)
            Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
            commit('SET_TOKEN', result.token)
            commit('SET_INFO', userInfo)
            commit('SET_NAME', { username: userInfo.username,realname: userInfo.realname, welcome: welcome() })
            commit('SET_AVATAR', userInfo.avatar)
            resolve(response)
          }else{
            resolve(response)
          }
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 登录
    Login({ commit }, userpara) {
      return new Promise((resolve, reject) => {
        login(userpara).then(response => {
		  console.dir(response)
		   
          if(response.isSuccess ==1){
            const result = response.data
            const userInfo = result.userInfo
			console.log('login ok userInfo:'+userInfo);
            Vue.ls.set(ACCESS_TOKEN, result.token, 7 * 24 * 60 * 60 * 1000)
            Vue.ls.set(USER_NAME, userInfo.username, 7 * 24 * 60 * 60 * 1000)
            Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
            commit('SET_TOKEN', result.token)
            commit('SET_INFO', userInfo)
            commit('SET_NAME', { username: userInfo.username,realname: userInfo.realname, welcome: welcome() })
            commit('SET_AVATAR', userInfo.avatar)
            resolve(response)
          }else{
            reject(response)
          }
        }).catch(error => {
          reject(error)
        })
      })
    },
    //手机号登录
    PhoneLogin({ commit }, userInfo) {
      return new Promise((resolve, reject) => {
          phoneLogin(userInfo).then(response => {
          if(response.code =='200'){
        const result = response.result
        const userInfo = result.userInfo
        Vue.ls.set(ACCESS_TOKEN, result.token, 7 * 24 * 60 * 60 * 1000)
        Vue.ls.set(USER_NAME, userInfo.username, 7 * 24 * 60 * 60 * 1000)
        Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
        commit('SET_TOKEN', result.token)
        commit('SET_INFO', userInfo)
        commit('SET_NAME', { username: userInfo.username,realname: userInfo.realname, welcome: welcome() })
        commit('SET_AVATAR', userInfo.avatar)
        resolve(response)
      }else{
        reject(response)
      }
    }).catch(error => {
        reject(error)
      })
    })
    },
    // 获取用户信息
    GetPermissionList({ commit }) {
      return new Promise((resolve, reject) => {
        let v_token = Vue.ls.get(ACCESS_TOKEN);
        let params = {token:v_token};
        queryPermissionsByUser(params).then(response => {
		  	
		    var localmenu=[
            {
                "redirect":null,
                "path":"/dashboard/analysis",
                "component":"dashboard/Analysis",
                "route":"1",
                "meta":{
                    "keepAlive":false,
                    "internalOrExternal":false,
                    "icon":"home",
                    "title":"首页"
                },
                "name":"dashboard-analysis",
                "id":"9502685863ab87f0ad1134142788a385"
            },
             
        
            {
                "redirect":null,
                "path":"/isystem",
                "component":"layouts/RouteView",
                "route":"1",
                "children":[
                    {
                        "path":"/isystem/user",
                        "component":"system/UserList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"用户管理"
                        },
                        "name":"isystem-user",
                        "id":"3f915b2769fc80648e92d04e84ca059d"
                    },
                    {
                        "path":"/isystem/newPermissionList",
                        "component":"system/NewPermissionList",
                        "route":"1",
                        "meta":{
                            "keepAlive":true,
                            "internalOrExternal":false,
                            "title":"菜单管理"
                        },
                        "name":"isystem-newPermissionList",
                        "id":"1170592628746878978"
                    },
                    {
                        "path":"/isystem/roleUserList",
                        "component":"system/RoleUserList",
                        "route":"1",
                        "meta":{
                            "keepAlive":true,
                            "internalOrExternal":false,
                            "title":"角色管理"
                        },
                        "name":"isystem-roleUserList",
                        "id":"190c2b43bec6a5f7a4194a85db67d96a"
                    },
                    {
                        "path":"/isystem/depart",
                        "component":"system/DepartList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"部门管理"
                        },
                        "name":"isystem-depart",
                        "id":"45c966826eeff4c99b8f8ebfe74511fc"
                    },
                    {
                        "path":"/isystem/dict",
                        "component":"system/DictList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"数据字典"
                        },
                        "name":"isystem-dict",
                        "id":"f1cb187abf927c88b89470d08615f5ac"
                    },
                    {
                        "path":"/isystem/departUserList",
                        "component":"system/DepartUserList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"我的部门"
                        },
                        "name":"isystem-departUserList",
                        "id":"5c2f42277948043026b7a14692456828"
                    },
                    {
                        "path":"/isystem/position",
                        "component":"system/SysPositionList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"职务管理"
                        },
                        "name":"isystem-position",
                        "id":"1174506953255182338"
                    },
                    {
                        "path":"/isys/category",
                        "component":"system/SysCategoryList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"分类字典"
                        },
                        "name":"isys-category",
                        "id":"ebb9d82ea16ad864071158e0c449d186"
                    },
					{
                        "path":"/isystem/TableList",
                        "component":"system/TableList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"表管理demo"
                        },
                        "name":"isystem-TableList",
                        "id":"6ad53fd1b222289a8b71ff482d573a5a"
                    },
                    {
                        "path":"/isystem/annountCement",
                        "component":"system/SysAnnouncementList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"系统通告"
                        },
                        "name":"isystem-annountCement",
                        "id":"e08cb190ef230d5d4f03824198773950"
                    }
                ],
                "meta":{
                    "keepAlive":false,
                    "internalOrExternal":false,
                    "icon":"setting",
                    "title":"系统管理"
                },
                "name":"isystem",
                "id":"d7d6e2e4e2934f2c9385a623fd98c6f3"
            },
            {
                "redirect":null,
                "path":"/report",
                "component":"layouts/RouteView",
                "route":"1",
                "children":[
                    {
                        "path":"/report/ViserChartDemo",
                        "component":"jeecg/report/ViserChartDemo",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"ViserChartDemo"
                        },
                        "name":"report-ViserChartDemo",
                        "id":"020b06793e4de2eee0007f603000c769"
                    },
                    {
                        "path":"/report/ArchivesStatisticst",
                        "component":"jeecg/report/ArchivesStatisticst",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"布局统计报表"
                        },
                        "name":"report-ArchivesStatisticst",
                        "id":"2aeddae571695cd6380f6d6d334d6e7d"
                    }
                ],
                "meta":{
                    "keepAlive":false,
                    "internalOrExternal":false,
                    "icon":"bar-chart",
                    "title":"统计报表"
                },
                "name":"report",
                "id":"f0675b52d89100ee88472b6800754a08"
            },
            {
                "redirect":"/kunlun",
                "path":"/kunlun",
                "component":"layouts/RouteView",
                "route":"1",
                "children":[
                    {
                        "path":"/online/graphreport/chart/27accd782f98c41eae5fad1b0514238d",
                        "component":"modules/online/graphreport/auto/OnlGraphreportAutoChart",
                        "route":"0",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"月度增长分析同比"
                        },
                        "name":"online-graphreport-chart-27accd782f98c41eae5fad1b0514238d",
                        "id":"0230a2c89be59104a1b048195150f2d0"
                    },
                    {
                        "path":"/online/graphreport/chart/1c034f6063cee129e6aa32016ac42ce8",
                        "component":"modules/online/graphreport/auto/OnlGraphreportAutoChart",
                        "route":"0",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"项目性质收入统计"
                        },
                        "name":"online-graphreport-chart-1c034f6063cee129e6aa32016ac42ce8",
                        "id":"326a99be05ab907332fad34944a906af"
                    },
                    {
                        "path":"b03ca6f3065d18bfec693c03b397ebd4",
                        "component":"layouts/IframeFReportView",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"年度同比报表",
                            "url":"{{ window._CONFIG['domianURL'] }}/ReportServer?reportlet=kunl_re1.cpt"
                        },
                        "name":"{{ window._CONFIG['domianURL'] }}-ReportServer?reportlet=kunl_re1.cpt",
                        "id":"e47142f2d104aa7f1ba0f9d360226be8"
                    },
                    {
                        "path":"ad5bbf92f2d82df8dc11c86111bc4144",
                        "component":"layouts/IframeFReportView",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"来源收入统计",
                            "url":"{{ window._CONFIG['domianURL'] }}/ReportServer?reportlet=kunlun_02.cpt"
                        },
                        "name":"{{ window._CONFIG['domianURL'] }}-ReportServer?reportlet=kunlun_02.cpt",
                        "id":"2aa1fc959c2d0d8f78ab936c8f8560fb"
                    }
                ],
                "meta":{
                    "keepAlive":false,
                    "internalOrExternal":false,
                    "icon":"sliders",
                    "title":"业务报表"
                },
                "name":"kunlun",
                "id":"f4b0985a992eca541c1914a118669f44"
            },
            {
                "redirect":null,
                "path":"/dashboard3",
                "component":"layouts/RouteView",
                "route":"1",
                "children":[
                    {
                        "path":"/monitor",
                        "component":"layouts/RouteView",
                        "route":"1",
                        "children":[
                            {
                                "path":"/monitor/redis/info",
                                "component":"modules/monitor/RedisInfo",
                                "route":"1",
                                "meta":{
                                    "keepAlive":false,
                                    "internalOrExternal":false,
                                    "title":"Redis监控"
                                },
                                "name":"monitor-redis-info",
                                "id":"8d1ebd663688965f1fd86a2f0ead3416"
                            },
                            {
                                "path":"/monitor/TomcatInfo",
                                "component":"modules/monitor/TomcatInfo",
                                "route":"1",
                                "meta":{
                                    "keepAlive":false,
                                    "internalOrExternal":false,
                                    "title":"Tomcat信息"
                                },
                                "name":"monitor-TomcatInfo",
                                "id":"024f1fd1283dc632458976463d8984e1"
                            },
                            {
                                "path":"/monitor/SystemInfo",
                                "component":"modules/monitor/SystemInfo",
                                "route":"1",
                                "meta":{
                                    "keepAlive":false,
                                    "internalOrExternal":false,
                                    "title":"服务器信息"
                                },
                                "name":"monitor-SystemInfo",
                                "id":"8b3bff2eee6f1939147f5c68292a1642"
                            },
                            {
                                "path":"/monitor/JvmInfo",
                                "component":"modules/monitor/JvmInfo",
                                "route":"1",
                                "meta":{
                                    "keepAlive":false,
                                    "internalOrExternal":false,
                                    "title":"JVM信息"
                                },
                                "name":"monitor-JvmInfo",
                                "id":"d07a2c87a451434c99ab06296727ec4f"
                            },
                            {
                                "path":"/monitor/HttpTrace",
                                "component":"modules/monitor/HttpTrace",
                                "route":"1",
                                "meta":{
                                    "keepAlive":false,
                                    "internalOrExternal":false,
                                    "title":"请求追踪"
                                },
                                "name":"monitor-HttpTrace",
                                "id":"fc810a2267dd183e4ef7c71cc60f4670"
                            },
                            {
                                "path":"/monitor/Disk",
                                "component":"modules/monitor/DiskMonitoring",
                                "route":"1",
                                "meta":{
                                    "keepAlive":false,
                                    "internalOrExternal":false,
                                    "title":"磁盘监控"
                                },
                                "name":"monitor-Disk",
                                "id":"97c8629abc7848eccdb6d77c24bb3ebb"
                            }
                        ],
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"性能监控"
                        },
                        "name":"monitor",
                        "id":"700b7f95165c46cc7a78bf227aa8fed3"
                    },
                    {
                        "path":"/isystem/log",
                        "component":"system/LogList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"日志管理"
                        },
                        "name":"isystem-log",
                        "id":"58857ff846e61794c69208e9d3a85466"
                    },
                    {
                        "path":"/sys/dataLog-list",
                        "component":"system/DataLogList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"数据日志"
                        },
                        "name":"sys-dataLog-list",
                        "id":"841057b8a1bef8f6b4b20f9a618a7fa6"
                    },
                    {
                        "path":"5f22d2592b01c9e964efe70040162b83",
                        "component":"layouts/IframePageView",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":true,
                            "title":"SQL监控",
                            "url":"{{ window._CONFIG['domianURL'] }}/druid/"
                        },
                        "name":"{{ window._CONFIG['domianURL'] }}-druid-",
                        "id":"aedbf679b5773c1f25e9f7b10111da73"
                    },
                    {
                        "path":"10b80437abc6eee8c3e3daabb5e9f59e",
                        "component":"layouts/IframePageView",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":true,
                            "title":"在线文档",
                            "url":"{{ window._CONFIG['domianURL'] }}/doc.html"
                        },
                        "name":"{{ window._CONFIG['domianURL'] }}-doc.html",
                        "id":"2dbbafa22cda07fa5d169d741b81fe12"
                    },
                    {
                        "path":"/isystem/QuartzJobList",
                        "component":"system/QuartzJobList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"定时任务"
                        },
                        "name":"isystem-QuartzJobList",
                        "id":"b1cb0a3fedf7ed0e4653cb5a229837ee"
                    },
                    {
                        "path":"/isps/userAnnouncement",
                        "component":"system/UserAnnouncementList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"我的消息"
                        },
                        "name":"isps-userAnnouncement",
                        "id":"53a9230444d33de28aa11cc108fb1dba"
                    }
                ],
                "meta":{
                    "keepAlive":false,
                    "internalOrExternal":false,
                    "icon":"dashboard",
                    "title":"系统监控"
                },
                "name":"dashboard3",
                "id":"08e6b9dc3c04489c8e1ff2ce6f105aa4"
            },
            {
                "redirect":null,
                "path":"/message",
                "component":"layouts/RouteView",
                "route":"1",
                "children":[
                    {
                        "path":"/modules/message/sysMessageList",
                        "component":"modules/message/SysMessageList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"消息管理"
                        },
                        "name":"modules-message-sysMessageList",
                        "id":"944abf0a8fc22fe1f1154a389a574154"
                    }
                ],
                "meta":{
                    "keepAlive":false,
                    "internalOrExternal":false,
                    "icon":"message",
                    "title":"消息中心"
                },
                "name":"message",
                "id":"5c8042bd6c601270b2bbd9b20bccc68b"
            },
            {
                "redirect":null,
                "path":"/jeecg",
                "component":"layouts/RouteView",
                "route":"1",
                "children":[
                    {
                        "path":"/jeecg/SelectDemo",
                        "component":"jeecg/SelectDemo",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"自定义组件"
                        },
                        "name":"jeecg-SelectDemo",
                        "id":"9a90363f216a6a08f32eecb3f0bf12a3"
                    },
                    {
                        "path":"/oss/file",
                        "component":"modules/oss/OSSFileList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"对象存储"
                        },
                        "name":"oss-file",
                        "id":"1166535831146504193"
                    },
                    {
                        "path":"/jeecg/jeecgDemoList",
                        "component":"jeecg/JeecgDemoList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"单表模型示例"
                        },
                        "name":"DemoList",
                        "id":"4148ec82b6acd69f470bea75fe41c357"
                    },
                    {
                        "path":"/jeecg/tablist/JeecgOrderDMainList",
                        "component":"jeecg/tablist/JeecgOrderDMainList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"一对多Tab示例"
                        },
                        "name":"jeecg-tablist-JeecgOrderDMainList",
                        "id":"6ad53fd1b220989a8b71ff482d683a5a"
                    },
                    {
                        "path":"/jeecg/JeecgOrderMainListForJEditableTable",
                        "component":"jeecg/JeecgOrderMainListForJEditableTable",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"一对多JEditable"
                        },
                        "name":"jeecg-JeecgOrderMainListForJEditableTable",
                        "id":"c431130c0bc0ec71b0a5be37747bb36a"
                    },
                    {
                        "path":"/jeecg/JeecgOrderMainList",
                        "component":"jeecg/JeecgOrderMainList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"一对多示例"
                        },
                        "name":"jeecg-JeecgOrderMainList",
                        "id":"fb367426764077dcf94640c843733985"
                    },
                    {
                        "path":"/jeecg/tableTotal",
                        "component":"jeecg/TableTotal",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"表格合计"
                        },
                        "name":"jeecg-tableTotal",
                        "id":"043780fa095ff1b2bec4dc406d76f023"
                    },
                    {
                        "path":"/jeecg/JeecgTreeTable",
                        "component":"jeecg/JeecgTreeTable",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"异步树列表Demo"
                        },
                        "name":"jeecg-JeecgTreeTable",
                        "id":"0620e402857b8c5b605e1ad9f4b89350"
                    },
                    {
                        "path":"/jeecg/PrintDemo",
                        "component":"jeecg/PrintDemo",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"打印测试"
                        },
                        "name":"jeecg-PrintDemo",
                        "id":"e6bfd1fcabfd7942fdd05f076d1dad38"
                    },
                    {
                        "path":"/jeecg/helloworld",
                        "component":"jeecg/helloworld",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"helloworld"
                        },
                        "name":"jeecg-helloworld",
                        "id":"339329ed54cf255e1f9392e84f136901"
                    },
                    {
                        "path":"/jeecg/TableExpandeSub",
                        "component":"jeecg/TableExpandeSub",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"内嵌Table"
                        },
                        "name":"jeecg-TableExpandeSub",
                        "id":"4356a1a67b564f0988a484f5531fd4d9"
                    },
                    {
                        "path":"bfa89e563d9509fbc5c6503dd50faf2e",
                        "component":"layouts/IframePageView",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"百度",
                            "url":"http://www.baidu.com"
                        },
                        "name":"http@--www.baidu.com",
                        "id":"a400e4f4d54f79bf5ce160ae432231af"
                    },
                    {
                        "path":"/jeecg/InterfaceTest",
                        "component":"jeecg/InterfaceTest",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"数据回执模拟"
                        },
                        "name":"jeecg-InterfaceTest",
                        "id":"c6cf95444d80435eb37b2f9db3971ae6"
                    },
                    {
                        "path":"/jeecg/JEditableTable",
                        "component":"jeecg/JeecgEditableTableExample",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"JEditableTable示例"
                        },
                        "name":"jeecg-JEditableTable",
                        "id":"7960961b0063228937da5fa8dd73d371"
                    },
                    {
                        "path":"/jeecg/imgDragSort",
                        "component":"jeecg/ImgDragSort",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"图片拖拽排序"
                        },
                        "name":"jeecg-imgDragSort",
                        "id":"265de841c58907954b8877fb85212622"
                    },
                    {
                        "path":"/jeecg/imgTurnPage",
                        "component":"jeecg/ImgTurnPage",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"图片翻页"
                        },
                        "name":"jeecg-imgTurnPage",
                        "id":"58b9204feaf07e47284ddb36cd2d8468"
                    },
                    {
                        "path":"/jeecg/ImagPreview",
                        "component":"jeecg/ImagPreview",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"图片预览"
                        },
                        "name":"jeecg-ImagPreview",
                        "id":"655563cd64b75dcf52ef7bcdd4836953"
                    },
                    {
                        "path":"/jeecg/jeecgPdfView",
                        "component":"jeecg/JeecgPdfView",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"PDF预览"
                        },
                        "name":"jeecg-jeecgPdfView",
                        "id":"e1979bb53e9ea51cecc74d86fd9d2f64"
                    },
                    {
                        "path":"/jeecg/splitPanel",
                        "component":"jeecg/SplitPanel",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"分屏"
                        },
                        "name":"jeecg-splitPanel",
                        "id":"3fac0d3c9cd40fa53ab70d4c583821f8"
                    }
                ],
                "meta":{
                    "keepAlive":false,
                    "internalOrExternal":false,
                    "icon":"qrcode",
                    "title":"常见案例"
                },
                "name":"jeecg",
                "id":"2a470fc0c3954d9dbb61de6d80846549"
            },
            {
                "redirect":null,
                "path":"/result",
                "component":"layouts/PageView",
                "route":"1",
                "children":[
                    {
                        "path":"/result/success",
                        "component":"result/Success",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"成功"
                        },
                        "name":"result-success",
                        "id":"00a2a0ae65cdca5e93209cdbde97cbe6"
                    },
                    {
                        "path":"/result/fail",
                        "component":"result/Error",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"失败"
                        },
                        "name":"result-fail",
                        "id":"13212d3416eb690c2e1d5033166ff47a"
                    }
                ],
                "meta":{
                    "keepAlive":false,
                    "internalOrExternal":false,
                    "icon":"check-circle-o",
                    "title":"结果页"
                },
                "name":"result",
                "id":"2e42e3835c2b44ec9f7bc26c146ee531"
            },
            {
                "redirect":null,
                "path":"/profile",
                "component":"layouts/RouteView",
                "route":"1",
                "children":[
                    {
                        "path":"/profile/basic",
                        "component":"profile/basic/Index",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"基础详情页"
                        },
                        "name":"profile-basic",
                        "id":"cc50656cf9ca528e6f2150eba4714ad2"
                    },
                    {
                        "path":"/profile/advanced",
                        "component":"profile/advanced/Advanced",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"高级详情页"
                        },
                        "name":"profile-advanced",
                        "id":"b3c824fc22bd953e2eb16ae6914ac8f9"
                    }
                ],
                "meta":{
                    "keepAlive":false,
                    "internalOrExternal":false,
                    "icon":"profile",
                    "title":"详情页"
                },
                "name":"profile",
                "id":"4875ebe289344e14844d8e3ea1edd73f"
            },
            {
                "redirect":null,
                "path":"/exception",
                "component":"layouts/RouteView",
                "route":"1",
                "children":[
                    {
                        "path":"/exception/403",
                        "component":"exception/403",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"403"
                        },
                        "name":"exception-403",
                        "id":"65a8f489f25a345836b7f44b1181197a"
                    },
                    {
                        "path":"/exception/404",
                        "component":"exception/404",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"404"
                        },
                        "name":"exception-404",
                        "id":"d2bbf9ebca5a8fa2e227af97d2da7548"
                    },
					{
                        "path":"/exception/505",
                        "component":"exception/505",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"505"
                        },
                        "name":"exception-505",
                        "id":"d2bbf9ebca5a8f22e227af97d2da7548"
                    },
                    {
                        "path":"/exception/500",
                        "component":"exception/500",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"500"
                        },
                        "name":"exception-500",
                        "id":"b4dfc7d5dd9e8d5b6dd6d4579b1aa559"
                    }
                ],
                "meta":{
                    "keepAlive":false,
                    "internalOrExternal":false,
                    "icon":"warning",
                    "title":"异常页"
                },
                "name":"exception",
                "id":"c65321e57b7949b7a975313220de0422"
            },
            {
                "redirect":"/list/query-list",
                "path":"/list",
                "component":"layouts/PageView",
                "route":"1",
                "children":[
                    {
                        "path":"/list/query-list",
                        "component":"list/TableList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"查询表格"
                        },
                        "name":"list-query-list",
                        "id":"418964ba087b90a84897b62474496b93"
                    },
                    {
                        "path":"/list/edit-table",
                        "component":"list/TableInnerEditList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"内联编辑表格"
                        },
                        "name":"list-edit-table",
                        "id":"ae4fed059f67086fd52a73d913cf473d"
                    },
                    {
                        "path":"/list/user-list",
                        "component":"list/UserList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"用户列表"
                        },
                        "name":"list-user-list",
                        "id":"05b3c82ddb2536a4a5ee1a4c46b5abef"
                    },
                    {
                        "path":"/list/role-list",
                        "component":"list/RoleList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"角色列表"
                        },
                        "name":"list-role-list",
                        "id":"4f84f9400e5e92c95f05b554724c2b58"
                    },
                    {
                        "path":"/list/permission-list",
                        "component":"list/PermissionList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"权限列表"
                        },
                        "name":"list-permission-list",
                        "id":"73678f9daa45ed17a3674131b03432fb"
                    },
                    {
                        "path":"/list/basic-list",
                        "component":"list/StandardList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"标准列表"
                        },
                        "name":"list-basic-list",
                        "id":"f23d9bfff4d9aa6b68569ba2cff38415"
                    },
                    {
                        "path":"/list/card",
                        "component":"list/CardList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"卡片列表"
                        },
                        "name":"list-card",
                        "id":"7ac9eb9ccbde2f7a033cd4944272bf1e"
                    },
                    {
                        "path":"/list/search",
                        "component":"list/search/SearchLayout",
                        "route":"1",
                        "children":[
                            {
                                "path":"/list/search/article",
                                "component":"list/TableList",
                                "route":"1",
                                "meta":{
                                    "keepAlive":false,
                                    "internalOrExternal":false,
                                    "title":"搜索列表（文章）"
                                },
                                "name":"list-search-article",
                                "id":"078f9558cdeab239aecb2bda1a8ed0d1"
                            },
                            {
                                "path":"/list/search/application",
                                "component":"list/TableList",
                                "route":"1",
                                "meta":{
                                    "keepAlive":false,
                                    "internalOrExternal":false,
                                    "title":"搜索列表（应用）"
                                },
                                "name":"list-search-application",
                                "id":"200006f0edf145a2b50eacca07585451"
                            },
                            {
                                "path":"/list/search/project",
                                "component":"list/TableList",
                                "route":"1",
                                "meta":{
                                    "keepAlive":false,
                                    "internalOrExternal":false,
                                    "title":"搜索列表（项目）"
                                },
                                "name":"list-search-project",
                                "id":"de13e0f6328c069748de7399fcc1dbbd"
                            }
                        ],
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"搜索列表"
                        },
                        "name":"list-search",
                        "id":"fb07ca05a3e13674dbf6d3245956da2e"
                    }
                ],
                "meta":{
                    "keepAlive":false,
                    "internalOrExternal":false,
                    "icon":"table",
                    "title":"列表页"
                },
                "name":"list",
                "id":"540a2936940846cb98114ffb0d145cb8"
            },
            {
                "redirect":null,
                "path":"/account",
                "component":"layouts/RouteView",
                "route":"1",
                "children":[
                    {
                        "path":"/account/center",
                        "component":"account/center/Index",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"个人中心"
                        },
                        "name":"account-center",
                        "id":"d86f58e7ab516d3bc6bfb1fe10585f97"
                    },
                    {
                        "path":"/account/settings/base",
                        "component":"account/settings/Index",
                        "route":"1",
                        "children":[
                            {
                                "path":"/account/settings/base",
                                "component":"account/settings/BaseSetting",
                                "route":"1",
                                "hidden":true,
                                "meta":{
                                    "keepAlive":false,
                                    "internalOrExternal":false,
                                    "title":"基本设置"
                                },
                                "name":"account-settings-base",
                                "id":"1367a93f2c410b169faa7abcbad2f77c"
                            },
                            {
                                "path":"/account/settings/binding",
                                "component":"account/settings/Binding",
                                "route":"1",
                                "meta":{
                                    "keepAlive":false,
                                    "internalOrExternal":false,
                                    "title":"账户绑定"
                                },
                                "name":"account-settings-binding",
                                "id":"4f66409ef3bbd69c1d80469d6e2a885e"
                            },
                            {
                                "path":"/account/settings/custom",
                                "component":"account/settings/Custom",
                                "route":"1",
                                "meta":{
                                    "keepAlive":false,
                                    "internalOrExternal":false,
                                    "title":"个性化设置"
                                },
                                "name":"account-settings-custom",
                                "id":"882a73768cfd7f78f3a37584f7299656"
                            },
                            {
                                "path":"/account/settings/security",
                                "component":"account/settings/Security",
                                "route":"1",
                                "meta":{
                                    "keepAlive":false,
                                    "internalOrExternal":false,
                                    "title":"安全设置"
                                },
                                "name":"account-settings-security",
                                "id":"ec8d607d0156e198b11853760319c646"
                            },
                            {
                                "path":"/account/settings/notification",
                                "component":"account/settings/Notification",
                                "route":"1",
                                "meta":{
                                    "keepAlive":false,
                                    "internalOrExternal":false,
                                    "title":"新消息通知"
                                },
                                "name":"account-settings-notification",
                                "id":"fedfbf4420536cacc0218557d263dfea"
                            }
                        ],
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"个人设置"
                        },
                        "name":"account-settings-base",
                        "id":"6e73eb3c26099c191bf03852ee1310a1",
                        "alwaysShow":true
                    },
                    {
                        "path":"/dashboard/workplace",
                        "component":"dashboard/Workplace",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"工作台"
                        },
                        "name":"dashboard-workplace",
                        "id":"8fb8172747a78756c11916216b8b8066"
                    }
                ],
                "meta":{
                    "keepAlive":false,
                    "internalOrExternal":false,
                    "icon":"user",
                    "title":"个人页"
                },
                "name":"account",
                "id":"717f6bee46f44a3897eca9abd6e2ec44"
            },
            {
                "redirect":null,
                "path":"/form",
                "component":"layouts/PageView",
                "route":"1",
                "children":[
                    {
                        "path":"/form/base-form",
                        "component":"form/BasicForm",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"基础表单"
                        },
                        "name":"form-base-form",
                        "id":"277bfabef7d76e89b33062b16a9a5020"
                    },
                    {
                        "path":"/form/step-form",
                        "component":"form/stepForm/StepForm",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"分步表单"
                        },
                        "name":"form-step-form",
                        "id":"6531cf3421b1265aeeeabaab5e176e6d"
                    },
                    {
                        "path":"/form/advanced-form",
                        "component":"form/advancedForm/AdvancedForm",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"高级表单"
                        },
                        "name":"form-advanced-form",
                        "id":"e5973686ed495c379d829ea8b2881fc6"
                    }
                ],
                "meta":{
                    "keepAlive":false,
                    "internalOrExternal":false,
                    "icon":"form",
                    "title":"表单页"
                },
                "name":"form",
                "id":"e3c13679c73a4f829bcff2aba8fd68b1"
            },
            {
                "redirect":null,
                "path":"/onlineceshi",
                "component":"layouts/RouteView",
                "route":"1",
                "children":[
                    {
                        "path":"/online/cgformList/81fcf7d8922d45069b0d5ba983612d3a",
                        "component":"modules/online/cgform/auto/OnlCgformAutoList",
                        "route":"0",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"online入职"
                        },
                        "name":"online-cgformList-81fcf7d8922d45069b0d5ba983612d3a",
                        "id":"1210037853075124225"
                    },
                    {
                        "path":"/hr/CeshiRuzhiList",
                        "component":"erp/hr/CeshiRuzhiList",
                        "route":"1",
                        "meta":{
                            "keepAlive":false,
                            "internalOrExternal":false,
                            "title":"编码入职单"
                        },
                        "name":"hr-CeshiRuzhiList",
                        "id":"1210089114260590594"
                    }
                ],
                "meta":{
                    "keepAlive":false,
                    "internalOrExternal":false,
                    "icon":"hourglass",
                    "title":"测试online"
                },
                "name":"onlineceshi",
                "id":"1210037401705099266"
            },
             
        ];
		  response.data.menu=localmenu
		  
          const menuData = response.data.menu;
          const authData = response.data.auth;
          const allAuthData = response.data.allAuth;
		  console.dir("menuData:"+menuData)
          //Vue.ls.set(USER_AUTH,authData);
          sessionStorage.setItem(USER_AUTH,JSON.stringify(authData));
          sessionStorage.setItem(SYS_BUTTON_AUTH,JSON.stringify(allAuthData));
          if (menuData && menuData.length > 0) {
            commit('SET_PERMISSIONLIST', menuData)
          } else {
            reject('getPermissionList: permissions must be a non-null array !')
          }
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
		
    // 登出
    Logout({ commit, state }) {
      return new Promise((resolve) => {
        let logoutToken = state.token;
        commit('SET_TOKEN', '')
        commit('SET_PERMISSIONLIST', [])
        Vue.ls.remove(ACCESS_TOKEN)
        //console.log('logoutToken: '+ logoutToken)
        logout(logoutToken).then(() => {
          //var sevice = "http://"+window.location.host+"/";
          //var serviceUrl = encodeURIComponent(sevice);
          //window.location.href = window._CONFIG['casPrefixUrl']+"/logout?service="+serviceUrl;
          resolve()
        }).catch(() => {
          resolve()
        })
      })
    },

  }
}

export default user